'''
@Descripttion: 
@version: 
@encoding: utf-8
@Author: qiurongcan
Date: 2025-09-22 17:15:43
LastEditTime: 2025-09-22 17:21:57
'''


from collections import defaultdict


class Solution:

    def groupAngrams(self, strs):

        d = defaultdict(list)
        for str in strs:
            # 进行排序
            sorted_s = "".join(sorted(str))
            d[sorted_s].append(str)

        
        return list(d.values())





